#pragma once
#include <cuda_runtime.h>
#include <cuda/helper_cuda.h>
#include <thrust\device_vector.h>
#include <thrust\host_vector.h>
#include <thrust\fill.h>

namespace shermit {

	#define GPUMalloc(ptr,size) cudaMalloc((void**)&ptr,size)
    #define CPU2GPU(dst,src,size) cudaMemcpy(dst, src, size, cudaMemcpyHostToDevice)
    #define GPU2CPU(dst,src,size) cudaMemcpy(dst, src, size, cudaMemcpyDeviceToHost)
    #define GPU2GPU(dst,src,size) cudaMemcpy(dst, src, size, cudaMemcpyDeviceToDevice)

    #define checkThrustErrors(func) \
	try {func;}					\
	catch (thrust::system_error &e) { std::cout << std::string(__FILE__) << ":" << __LINE__ << " " << e.what() << std::endl; }


	// thrust utils
	template<class T>
	inline __host__ T* getRawPtr(thrust::device_vector<T> &V) {
		return thrust::raw_pointer_cast(V.data());
	}

	template<class T>
	inline __host__ thrust::device_ptr<T> getDevicePtr(T* V) {
		return thrust::device_ptr<T>(V);
	}

}
